package tpf.designer.pattern.course5.structure_pattern2.flyweight_13.simple_2;

import org.apache.log4j.Logger;

/**
 * 享元对象
 */
public class ConcreteFlyweight implements Flyweight{

    public static final Logger LOGGER = Logger.getLogger(ConcreteFlyweight.class);

    /**
     * 示例，描述内部状态
     */
    private String intrinsicState;
    /**
     * 构造方法，传入享元对象的内部状态的数据
     * @param state 享元对象的内部状态的数据
     */
    public ConcreteFlyweight(String state){
        this.intrinsicState = state;
    }

    public void operation(String extrinsicState) {
        //具体的功能处理，可能会用到享元内部、外部的状态
        LOGGER.info("需要共享的flyweight对象");
        LOGGER.info("\n 内蕴状态：" + intrinsicState + ", 外蕴状态：" + extrinsicState);
    }
}